/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package network.packets;

import utils.Utils;

/**
 *
 * @author kvest
 */
public class SrvTransferDataResponce extends Packet
{
    private byte[] body;
    private int packetNumber;
    
    public SrvTransferDataResponce(byte[] data)
    {
        super(SRV_TRANSFER_DATA_RESPONCE);
        body = null;
        packetNumber = -1;
    
        parse(data);
    }

    protected void parse(byte[] data)
    {
        int offset = 0;

        //Пропускаем название пакета
        byte[] buffer4 = new byte[4];
        System.arraycopy(data, offset, buffer4, 0, buffer4.length);
        offset += buffer4.length + Utils.byteToInt(buffer4);

        //Какие то ненужные параметры
        System.arraycopy(data, offset, buffer4, 0, buffer4.length);
        offset += buffer4.length + Utils.byteToInt(buffer4);
	offset += 4 + 4 + 16 + 1;

	//Body
        System.arraycopy(data, offset, buffer4, 0, buffer4.length);
        offset += buffer4.length;
        body = new byte[Utils.byteToInt(buffer4)];
        System.arraycopy(data, offset, body, 0, body.length);
        offset += body.length;
        
        //packetNumber
        System.arraycopy(data, offset, buffer4, 0, buffer4.length);
        offset += buffer4.length;
        packetNumber = Utils.byteToInt(buffer4);

        buffer4 = null;
    }

    public byte[] getBody()
    {
        return body;
    }

    public int getPacketNumber()
    {
        return packetNumber;
    }
}
